package com.zte.user.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zte.user.dao.IUserDao;
import com.zte.user.model.Course;
import com.zte.user.model.Student;
import com.zte.user.model.Teacher;
import com.zte.user.model.Users;
import com.zte.user.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional
public class IUsreServiceImpl implements IUserService {
    @Autowired
    private IUserDao userDao;

    @Override
    public List<Users> login(Users users) {
        return userDao.login(users);
    }

    @Override
    public List<Users> findAll(Users users) {
        return userDao.findAll(users);
    }

    @Override
    public Student findAllStudent(Student student) {
        return userDao.findAllStudent(student);
    }

    @Override
    public Teacher findAllTeacher(Teacher teacher) {
        return userDao.findAllTeacher(teacher);
    }

    @Override
    public List<Student> findAllStudents() {
        return userDao.findAllStudents();
    }

    @Override
    public List<Teacher> findAllTeachers() {
        return userDao.findAllTeachers();
    }

    @Override
    public List<Course> findAllCourses() {
            return userDao.findAllCourses();
    }

    @Override
    public Course findAllCourse(Course course) {
        return userDao.findAllCourse(course);
    }

    @Override
    public PageInfo<Users> findPagebyAll(PageInfo<Users> info, Users users) {
        PageHelper.startPage(info.getPageNum(),info.getPageSize());
        List<Users> users1 = userDao.findAll(users);
        PageInfo<Users> pageInfo = new PageInfo<>(users1);
        return pageInfo;
    }

    @Override
    public PageInfo<Student> findPagebyAllStu(PageInfo<Student> pageInfo1, Student student) {
        PageHelper.startPage(pageInfo1.getPageNum(),pageInfo1.getPageSize());
        List<Student> students = userDao.findAllStudents();
        PageInfo<Student> pageInfo = new PageInfo<>(students);
        return pageInfo;
    }

    @Override
    public PageInfo<Teacher> findPagebyAllTeacher(PageInfo<Teacher> pageInfo2, Teacher teacher) {
        PageHelper.startPage(pageInfo2.getPageNum(),pageInfo2.getPageSize());
        List<Teacher> teachers = userDao.findAllTeachers();
        PageInfo<Teacher> pageInfo = new PageInfo<>(teachers);
        return pageInfo;
    }

    @Override
    public boolean addStu(Student student) {
        return userDao.addStu(student);
    }

    @Override
    public boolean addUser(Users users) {
        return userDao.addUser(users);
    }

    @Override
    public boolean addTeacher(Teacher teacher) {
        return userDao.addTeacher(teacher);
    }

    @Override
    public boolean addCourse(Course course) {
        return userDao.addCourse(course);
    }

    @Override
    public boolean updateStu(Student student) {
        return userDao.updateStu(student);
    }

    @Override
    public boolean updateUser(Users users) {
        return userDao.updateUser(users);
    }

    @Override
    public boolean updateTeacher(Teacher teacher) {
        return userDao.updateTeacher(teacher);
    }

    @Override
    public boolean updateTeacherper(Teacher teacher) {
        return userDao.updateTeacherper(teacher);
    }

    @Override
    public boolean updateStu1(Student student) {
        return userDao.updateStu1(student);
    }

    @Override
    public boolean updateCourse(Course course) {
        return userDao.updateCourse(course);
    }

    @Override
    public boolean deleteUser(Users users) {
        return userDao.deleteUser(users);
    }

    @Override
    public boolean deleteStudent(Student student) {
        return userDao.deleteStudent(student);
    }

    @Override
    public boolean deleteTeacher(Teacher teacher) {
        return userDao.deleteTeacher(teacher);
    }
    @Override
    public boolean deleteCourse(Course course) {
        return userDao.deleteCourse(course);
    }
}
